package org.goodsl.mdd.validator ;

import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
import org.goodsl.mdd.SingleValidResult;
import org.goodsl.mdd.Seg;

import org.goodsl.mdd.Validator;

/**
 * Created with IntelliJ IDEA.
 * User: Simon Xiao
 * Date: 12-11-14
 * Time: 上午8:51
 * To change this template use File | Settings | File Templates.
 */
public class AssertFalseValidator extends Validator<Seg> {
    public AssertFalseValidator(String message) {
        super(message);

    }

    @Override
    public SingleValidResult<Seg> verify(Seg variable) {

        Object value = variable.getValue();
        if (!DefaultTypeTransformation.castToBoolean(value))
            return new SingleValidResult<Seg>(true, "", variable, this);
        else
            return new SingleValidResult<Seg>(false, getMessage(), variable, this);
    }

}
